package com.heima.freemarker.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.*;

/**
 * @author itheima
 * @since 2022-07-04
 */
@Controller
public class HelloController {

    @GetMapping("/hello")
    public String hello(Model model) {

        model.addAttribute("name", "heima");
        model.addAttribute("age", 20);
        model.addAttribute("city", "beijing");

        Map<String, Object> stu = new HashMap<>();
        stu.put("name", "itcast");
        stu.put("age", 18);
        model.addAttribute("stu", stu);

        Map<String, Object> stu2 = new HashMap<>();
        stu2.put("name", "itheima");
        stu2.put("age", 16);

        List<Map<String, Object>> list = new ArrayList<>();
        list.add(stu);
        list.add(stu2);

        model.addAttribute("stus", list);
        model.addAttribute("today", new Date());

        return "01-basic";
    }

}
